<nz-modal [(nzVisible)]="isVisible" [nzMaskClosable]="false" [nzTitle]="academy.id ? '学院信息详情' : '新增学院信息'"
  (nzOnCancel)="handleCancel()" [nzFooter]="detailFooter" nzWidth="400">

  <form nz-form [formGroup]="validateForm" #academyForm="ngForm">
    <nz-form-item>
      <nz-form-label nzRequired [nzSpan]="6" nzFor="code">学院编码</nz-form-label>
      <nz-form-control [nzSpan]="14" nzHasFeedback nzValidatingTip="验证中..." [nzErrorTip]="codeErrorTpl">
        <input nz-input formControlName="code" [(ngModel)]="academy.code" placeholder="学院编码必填"
          *ngIf="!isPreView; else codeTemp">
        <ng-template #codeErrorTpl let-control>
          <ng-container *ngIf="control.hasError('required')">
            请输入学院编码!
          </ng-container>
          <ng-container *ngIf="control.hasError('duplicated')">
            该学院编码已存在!
          </ng-container>
          <ng-container *ngIf="control.hasError('blank')">
            不可输入空格!
          </ng-container>
        </ng-template>
        <ng-template #codeTemp>
          <div class="editable-cell">
            <div class="editable-cell-value-wrap text-truncate">
              {{ academy?.code }}
            </div>
          </div>
        </ng-template>
      </nz-form-control>
    </nz-form-item>
    <nz-form-item>
      <nz-form-label nzRequired [nzSpan]="6" nzFor="name">学院名称</nz-form-label>
      <nz-form-control [nzSpan]="14" nzHasFeedback nzValidatingTip="验证中..." [nzErrorTip]="nameErrorTpl">
        <input nz-input formControlName="name" [(ngModel)]="academy.name" placeholder="学院名称必填"
          *ngIf="!isPreView; else nameTemp">
        <ng-template #nameErrorTpl let-control>
          <ng-container *ngIf="control.hasError('required')">
            请输入学院名称!
          </ng-container>
          <ng-container *ngIf="control.hasError('pattern')">
            不能存在空格字符!
          </ng-container>
        </ng-template>
        <ng-template #nameTemp>
          <div class="editable-cell">
            <div class="editable-cell-value-wrap text-truncate">
              {{ academy?.name }}
            </div>
          </div>
        </ng-template>
      </nz-form-control>
    </nz-form-item>
    <nz-form-item>
      <nz-form-label nzRequired [nzSpan]="6" nzFor="shortName">学院简称</nz-form-label>
      <nz-form-control [nzSpan]="14" nzHasFeedback nzErrorTip="MaxLength is 10">
        <input nz-input formControlName="shortName" [(ngModel)]="academy.shortName" placeholder="学院简称选填"
          *ngIf="!isPreView; else shortNameTemp" maxlength="10">
        <ng-template #shortNameTemp>
          <div class="editable-cell">
            <div class="editable-cell-value-wrap text-truncate">
              {{ academy?.shortName }}
            </div>
          </div>
        </ng-template>
      </nz-form-control>
    </nz-form-item>
    <nz-form-item>
      <nz-form-label nzFor="showOrder" nzRequired [nzSpan]="6">显示顺序</nz-form-label>
      <nz-form-control [nzSpan]="14">
        <nz-input-number [(ngModel)]="academy.showOrder" [nzMin]="0" [nzStep]="1" formControlName="showOrder"
          *ngIf="!isPreView; else showOrderTemp">
        </nz-input-number>
        <ng-template #showOrderTemp>
          <div class="editable-cell">
            <div class="editable-cell-value-wrap text-truncate">
              {{ academy?.showOrder }}
            </div>
          </div>
        </ng-template>
      </nz-form-control>
    </nz-form-item>
  </form>

  <ng-template #detailFooter>
    <button nz-button nzType="primary" (click)="save()" *ngIf="!isPreView" [nzLoading]="loading">
      <span>保存</span>
    </button>
    <button nz-button nzType="default" (click)="handleCancel()">关闭</button>
  </ng-template>
</nz-modal>
